package com.gzhryc.shared_device.common.payment.dao.db;

import java.util.Date;

import com.gzhryc.common.NumberTools;
import com.gzhryc.common.json.JsonTools;
import com.gzhryc.jdbc.annotaion.Column;
import com.gzhryc.jdbc.annotaion.Id;
import com.gzhryc.jdbc.annotaion.Table;
import com.gzhryc.pay.adaptation.weixin.msg.WXReceivingInfo;
import com.gzhryc.pay.enums.ReceivingMoneyType;
import com.gzhryc.pay.models.ITransferMoneyOrder;
import com.gzhryc.shared_device.base.enums.ETransferState;
import com.gzhryc.shared_device.common.payment.dao.enums.WXPayConfigEnum;

/**
 *  微信转账订单
 * @version 2023-01-04
 */
@Table(name="payment_wx_transfer_money_order")
public class WXTransferMoneyOrder implements ITransferMoneyOrder {

    private static final long serialVersionUID = 1L;

	@Id(auto = false)
    @Column(name = "trade_no",notNull = true,note = "订单号")
    protected String tradeNo;

    @Column(length = 255, note = "描述")
    protected String note;

    @Column(length = 8, notNull = true)
    protected Integer money;

    @Column(name = "transfer_account", note = "转账账号")
    protected String transferAccount;

    @Column(name="app_type",notNull = true,note = "应用类型")
    protected Integer appType;

    @Column(name = "app_id", notNull = true, note = "应用ID")
    protected String appId;

    @Column(name="open_id",notNull = true,note = "用户第三方ID")
    protected String openId;

    @Column(name="nickname",note = "微信用户昵称")
    protected String nickname;

    @Column(name="name",note = "用户姓名")
    protected String name;

    @Column(name="face_img",length = 255,note = "微信用户头像")
    protected String faceImg;

    @Column(name="phone",length = 16,note = "微信用户手机号")
    protected String phone;

    @Column(name = "external_trade_no", length = 64, note = "第三方转账订单编号")
    protected String externalTradeNo;

    @Column(name = "external_content", type = "TEXT", note = "第三方转账内容")
    protected String externalContent;

    @Column(name = "transfer_status", notNull = true,defVal = "1",note = "转账状态")
    protected Integer transferStatus;

    @Column(name = "fail_note", length = 255, note = "失败描述")
    protected String failNote;

    @Column(name = "update_date", note = "修改时间", autoUpdateTime = true)
    protected Date updateDate;

    @Column(name = "create_date", note = "创建时间")
    protected Date createDate;

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Integer getMoney() {
        return money;
    }

    public void setMoney(Integer money) {
        this.money = money;
    }

    public String getTransferAccount() {
        return transferAccount;
    }

    public void setTransferAccount(String transferAccount) {
        this.transferAccount = transferAccount;
    }

    public Integer getAppType() {
        return appType;
    }

    public void setAppType(Integer appType) {
        this.appType = appType;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFaceImg() {
        return faceImg;
    }

    public void setFaceImg(String faceImg) {
        this.faceImg = faceImg;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getExternalTradeNo() {
        return externalTradeNo;
    }

    public void setExternalTradeNo(String externalTradeNo) {
        this.externalTradeNo = externalTradeNo;
    }

    public String getExternalContent() {
        return externalContent;
    }

    public void setExternalContent(String externalContent) {
        this.externalContent = externalContent;
    }

    public Integer getTransferStatus() {
        return transferStatus;
    }

    public void setTransferStatus(Integer transferStatus) {
        this.transferStatus = transferStatus;
    }

    public String getFailNote() {
        return failNote;
    }

    public void setFailNote(String failNote) {
        this.failNote = failNote;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getTransferStatusName() {
        return ETransferState.note(this.transferStatus);
    }

    public Integer getReceivingType() {
        return ReceivingMoneyType.Account.index();
    }

    public String getMoneyStr(){
        return NumberTools.getMoneyStr(this.money);
    }

    public String getAppTypeName(){
        return WXPayConfigEnum.AppType.note(this.appType);
    }

    @Override
    public String getReceivingInfo() {
        WXReceivingInfo info = new WXReceivingInfo();
        info.setAppId(this.appId);
        info.setOpenid(this.openId);
        info.setNickname(this.nickname);
        return JsonTools.toJson(info);
    }
}
